<script>
import {getHomeworkSubmit} from "../../api/apiz";
import questionnairework from "./questionnairework.vue";
import filework from "./fileworkDetail.vue";

export default {
  name: "workstats",
  components: {questionnairework,filework},
  data() {
    return {
      title: "提交情况",
      visibleForm: false,
      queryParam: {
        pageNum: 1,
        pageSize: 10,
      },
      totalArr: 0,
      tableData: [],
      dialogVisible: false,
      dialogVisible1: false
    }
  },
  methods: {
    getWorkData(data) {
      let params = {
        pageNum: this.queryParam.pageNum,
        pageSize: this.queryParam.pageSize,
        taskOriginId: data.id
      }
      getHomeworkSubmit(params).then(res => {
        if (res.code == 200) {
          this.tableData = res.result.records
          this.totalArr = res.result.total
        } else {
          this.$message.warning(res.message)
        }
      })
      this.visibleForm = true;
    },
    handleCance() {
      this.visibleForm = false;
    },
    // 查看详情
    handleDetail(data) {
      if (data.type == 1) {
        //上传类型
        this.dialogVisible1 = true
        this.$nextTick(() => {
          this.$refs.filework.getDetail(data.studentId,data.taskOriginId)
        })
        return
      }
      if (data.type == 2) {
        //问卷类型
        this.dialogVisible = true
        this.$nextTick(() => {
          this.$refs.questionnairework.getDetail(data.studentId,data.taskOriginId)
        })
        return
      }
    }
  }

}
</script>

<template>
  <div class="workstate">
    <a-modal :title="title" :width="800" :visible="visibleForm" @cancel="handleCance" :closable="false" style="top:5%;height: 85%;overflow-y: hidden">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="studentName" label="学生姓名" align="center"></el-table-column>
        <el-table-column prop="createTime" label="提交时间" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="text" @click="handleDetail(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <template slot="footer">
        <el-button type="primary" @click.stop="handleCance">返回</el-button>
      </template>
    </a-modal>
    <!-- 上传文件 -->
    <el-dialog title="作业详情" :visible.sync="dialogVisible1" width="45%" top="5vh" append-to-body>
      <filework ref="filework" v-if="dialogVisible1"></filework>
    </el-dialog>
    <!-- 问卷调查 -->
    <el-dialog title="作业详情" :visible.sync="dialogVisible" width="45%" top="5vh" append-to-body>
      <questionnairework ref="questionnairework" v-if="dialogVisible"></questionnairework>
    </el-dialog>
  </div>
</template>

<style scoped lang="less">

</style>
